PYBLUEZ_VERSION=0.9.2
PYBLUEZ_BINARY=pybluez
PYBLUEZ_SOURCE=$(PYBLUEZ_BINARY)-src-$(PYBLUEZ_VERSION).tar.gz
PYBLUEZ_SITE=http://org.csail.mit.edu/pybluez/release/
PYBLUEZ_DIR=$(BUILD_DIR)/$(PYBLUEZ_BINARY)-$(PYBLUEZ_VERSION)
PYBLUEZ_SITE_PKG=$(TARGET_DIR)/usr/lib/python2.4/site-packages/

$(DL_DIR)/$(PYBLUEZ_SOURCE):
	$(WGET) -P $(DL_DIR) $(PYBLUEZ_SITE)/$(PYBLUEZ_SOURCE)

$(PYBLUEZ_DIR)/.source: $(DL_DIR)/$(PYBLUEZ_SOURCE)
	tar -C $(BUILD_DIR) -zxf $(DL_DIR)/$(PYBLUEZ_SOURCE)
	toolchain/patch-kernel.sh $(PYBLUEZ_DIR) package/pybluez/ pybluez\*.patch
	touch $(PYBLUEZ_DIR)/.source

$(PYBLUEZ_DIR)/.configured: $(PYBLUEZ_DIR)/.source
	touch $(PYBLUEZ_DIR)/.configured

$(PYBLUEZ_BINARY): python bluez-libs $(PYBLUEZ_DIR)/.configured
	mkdir -p $(PYBLUEZ_SITE_PKG)
	$(MAKE) -C $(PYBLUEZ_DIR) install

$(PYBLUEZ_BINARY)-clean:
	$(MAKE) -C $(PYBLUEZ_DIR) clean
	rm -rf $(PYBLUEZ_SITE_PKG)/bluetooth.py
	rm -rf $(PYBLUEZ_SITE_PKG)/_bluetooth.so

$(PYBLUEZ_BINARY)-dirclean:
	rm -rf $(PYBLUEZ_DIR)

ifeq ($(strip $(BR2_PACKAGE_PYBLUEZ)),y)
TARGETS+=$(PYBLUEZ_BINARY)
endif
